package com.cbank.controller.homepage;

import com.cbank.domain.ModuleShowDetail;
import com.cbank.service.ModuleShowDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
@RequestMapping("/moduleshowdetail")
public class ModuleShowDetailController {
    @Autowired
    private ModuleShowDetailService moduleShowDetailService;

    /**
     *根据模块的ID和模块下的type选择展示文章/链接
     * @param moduleShowId
     * @param type
     * @param model
     * @return
     */
    public String moduleShowDetailByModuleShowId(@RequestParam(value = "moduleShowId",required = true)Integer moduleShowId, @RequestParam(value = "type",required = true)Integer type,Model model){
        List<ModuleShowDetail> moduleShowDetailList=this.moduleShowDetailService.getListByModuleShowIdAndType(moduleShowId,type);
        model.addAttribute("moduleShowDetailList",moduleShowDetailList);
        return "";
    }

    /**
     * 根据moduleShowDetailId展示moduleShowDetail的详细信息
     * @param moduleShowDetailId
     * @param model
     * @return
     */
    public String moduleShowDetailByModuleShowDetailId(@RequestParam(value = "moduleShowDetailId",required = true)Integer moduleShowDetailId,Model model){
        ModuleShowDetail moduleShowDetail=this.moduleShowDetailService.getById(moduleShowDetailId);
        model.addAttribute("moduleShowDetail",moduleShowDetail);
        return "";
    }
}
